import requests
from lxml import etree
url = 'https://7a5bf1c6ac334308bed3eaadd68e7e0e.pbidedicated.windows.net/webapi/capacities/7A5BF1C6-AC33-4308-BED3-EAADD68E7E0E/workloads/QES/QueryExecutionService/automatic/public/query'
# url = "https://ourwayforward.wfu.edu/covid-19-dashboard/#"


headers =   {
            # "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36"
            #     ':authority': '7a5bf1c6ac334308bed3eaadd68e7e0e.pbidedicated.windows.net',
            #     ':method': 'POST',
            #     ':path': '/webapi/capacities/7A5BF1C6-AC33-4308-BED3-EAADD68E7E0E/workloads/QES/QueryExecutionService/automatic/public/query',
            #     ':scheme': 'https',
                'accept': 'application/json, text/plain, */*',
                'accept-encoding': 'gzip, deflate, br',
                'accept-language': 'zh-CN,zh;q=0.9',
                'activityid': 'c5e00f7a-b37c-7882-589f-a954d95def17',
                'authorization': 'MWCToken eyJhbGciOiJSUzI1NiIsImtpZCI6Ijk1QzkxQUYyOTE0ODAzNjY2MUJCRDcxMUI0MEFGMUNCMDdGRDAwRTMiLCJ0eXAiOiJKV1QiLCJ4NXQiOiJsY2thOHBGSUEyWmh1OWNSdEFyeHl3ZjlBT00ifQ.eyJvcmlnaW5hbEF1dGhvcml6YXRpb25IZWFkZXIiOiJCZWFyZXIgZXlKMGVYQWlPaUpLVjFRaUxDSmhiR2NpT2lKU1V6STFOaUlzSW5nMWRDSTZJbXd6YzFFdE5UQmpRMGcwZUVKV1dreElWRWQzYmxOU056WTRNQ0lzSW10cFpDSTZJbXd6YzFFdE5UQmpRMGcwZUVKV1dreElWRWQzYmxOU056WTRNQ0o5LmV5SmhkV1FpT2lKb2RIUndjem92TDJGdVlXeDVjMmx6TG5kcGJtUnZkM011Ym1WMEwzQnZkMlZ5WW1rdllYQnBJaXdpYVhOeklqb2lhSFIwY0hNNkx5OXpkSE11ZDJsdVpHOTNjeTV1WlhRdk0yTmxOR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content-length': '1392',
                'content-type': 'application/json;charset=UTF-8',
                'origin': 'https://app.powerbi.com',
                'pragma': 'no-cache',
                'referer': 'https://app.powerbi.com/',
                'requestid': 'f8ca3e42-1a7d-7a5e-5c6c-5343ee82f1e6',
                'sec-ch-ua': '\"Google Chrome\";v=\"93\", \" Not;A Brand\";v=\"99\", \"Chromium\";v=\"93\"',
                'sec-ch-ua-mobile': '?0',
                'sec-ch-ua-platform': "Windows",
                'sec-fetch-dest': 'empty',
                'sec-fetch-mode': 'cors',
                'sec-fetch-site': 'cross-site',
                'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36',
                'x-ms-parent-activity-id': '45bea965-eb77-c2da-a1e6-fc9b6a90e65b',
                'x-ms-workload-resource-moniker': 'ecb375d0-c062-4a1b-b2b3-cb1259fa2406'
            }

resp = requests.post(url = url,headers = headers)

print(resp.text)

exit(0)
html = etree.HTML(resp.text)
# /html/body/div[6]/div/div/div[2]/div[5]/div[1]/div[1]

divs = html.xpath('/html/body/div[2]/root/div/div/div[1]/div/div/div/exploration-container/div/div/div/exploration-host/div/div/exploration/div/explore-canvas/div/div[2]/div/div[2]/div[2]/visual-container-repeat/visual-container[5]/transform/div/div[3]/div/visual-modern/div/svg')
print(divs)
for div in divs:
    price = div.xpath('./div/div/a[2]/div[2]/div[1]/span[1]/text()')
    '/html/body/div[6]/div/div/div[2]/div[5]/div[1]/div[1]/div/div/a[2]/div[2]/div[1]/span[2]'
    print(price)

# 9
# /html/body/div[6]/div/div/div[2]/div[5]/div[1]/div[2]/div/div/a[2]/div[2]
# =INDIRECT("Sheet1!C"&CELL("row")) - INDIRECT("Sheet1!C"&(CELL("row")-1))


from selenium import webdriver
from lxml import  etree
from time import sleep

bro = webdriver.Chrome(executable_path='./chromedriver.exe')

bro.get('https://ourwayforward.wfu.edu/covid-19-dashboard/#')

# 获取浏览器当前页面的页面源码数据
page_text = bro.page_source

'//*[@id="gzlist"]'

# 解析企业名称

tree = etree.HTML(page_text)
li_list = tree.xpath('//*[@id="pvExplorationHost"]/div/div/exploration/div/explore-canvas/div/div[2]/div/div[2]/div[2]/visual-container-repeat/visual-container[5]/transform/div/div[3]/div/visual-modern/div/svg')
for li in li_list:
    name = li.xpath('./dl/@title')[0]
    print(name)


sleep(4)
bro.quit()

